/*

Copyright (C) 2010 Hans-Werner Hilse <hilse@web.de>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

*/

package de.hilses.droidreader;


import java.lang.String;

/**
 * Class that just loads the JNI lib and holds some basic configuration
 */
public final class PdfRender {
	/**
	 * how much bytes are stored for one pixel
	 */
	protected static int bytesPerPixel = 4;
	/**
	 * how much memory is the MuPDF backend allowed to use
	 */
	protected static int fitzMemory = 512 * 1024;

	/**
	 * the FontProvider instance that is queried from JNI code
	 */
	protected static FontProvider fontProvider = new NullFontProvider();

	static {
		/* JNI: load our native library */
		System.loadLibrary("pdfrender");
	}

	/**
	 * just checks if a given file can be accessed from JNI code
	 * @param fname the filename to check for
	 * @return 0 if the file was found, libc's errno otherwise
	 */
	private static native int nativeCheckFont(String fname);

	/**
	 * convenience method to check if a file is present and accessible from native code
	 * @param fname the filename to check for
	 * @return true if the file is there and we can read it, false otherwise
	 */
	static boolean checkFont(String fname) {
		return (nativeCheckFont(fname) == 0);
	}

	/**
	 * Sets a new FontProvider
	 * @param newProvider the new FontProvider
	 */
	public static void setFontProvider(FontProvider newProvider) {
		fontProvider = newProvider;
	}
}
